let arr = require("./data.js");

let { Article } = require("../model/index");

function initData() {
  Article.count().then((r) => {
    // console.log(r);
    // console.log(arr.length);
    if (r == 0) {
      console.log("插入20条测试商品数据");
      arr.forEach((v) => {
        let title = v.name;
        let content = v.name;
        let coverImg = "https:" + v.imgprefix + v.imgbase;
        let type = "all";
        let price = v.price;
        new Article({ title, content, coverImg, type, price }).save();
      });
    }
  });
}
module.exports = initData;
